<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    
        <h:form id="frmFirstName">
            <p:growl id="messageGeneral" showDetail="true" sticky="false" />
            
            <p:dataTable id="tabListFirstName" var="itemFirstName" 
                         value="#{mbVFirstName.all}" paginator="true" rows="10" 
                         paginatorPosition="bottom"
                         paginatorTemplate="{CurrentPageReport} {FirstPageLink} 
                                            {PreviousPageLink} {PageLinks} 
                                            {NextPageLink} {LastPageLink}"
                         emptyMessage="Нет имен"
                         filteredValue="#{mbVFirstName.listFirstNameFiltered}">
                    <f:facet name="header">
                        Имена                            
                    </f:facet>
                    <p:column width="100" headerText="Имя" filterBy="name">
                        <h:outputText value="#{itemFirstName.name}"/>
                    </p:column>
                    <p:column width="100">
                        <p:commandButton icon="ui-icon-disk" 
                                         action="#{mbVFirstName.setFirstNameParent()}"
                                         oncomplete="dialogFirstName.hide()"
                                         style="float:right;width:32px;height:32px;">
                            <f:setPropertyActionListener value="#{itemFirstName}"
                                                         target="#{mbVFirstName.firstName}" />
                        </p:commandButton>
                        <p:commandButton icon="ui-icon-trash"
                                         oncomplete="deleteFirstNameDlg.show()"
                                         style="float:right;width:32px;height:32px;">
                            <f:setPropertyActionListener value="#{itemFirstName}"
                                                         target="#{mbVFirstName.firstName}" />
                        </p:commandButton>
                        <p:commandButton update=":frmFirstName:editFirstNameDialog" 
                                         icon="ui-icon-pencil"
                                         oncomplete="editFirstNameDlg.show()"
                                         style="float:right;width:32px;height:32px;">
                            <f:setPropertyActionListener value="#{itemFirstName}"
                                                         target="#{mbVFirstName.firstName}" />
                        </p:commandButton>                
                    </p:column>
                </p:dataTable>
                <h:panelGroup layout="block" style="text-align: right">
                    <p:commandButton value="Новое имя" 
                                     oncomplete="newFirstNameDlg.show()" />
                </h:panelGroup>
               
                <!-- Add new FirstName -dialog -->
                <p:dialog widgetVar="newFirstNameDlg" id="newFirstNameDialog"
                          header="Новое имя" hideEffect="fade" 
                          showEffect="fade" resizable="false" closable="true">
                    <p:outputLabel value="Имя" for="txtFirstName"/>
                    <p:inputText id="txtFirstName" label="Имя" size="50" 
                                 value="#{mbVFirstName.newName}">
                    </p:inputText>
                    <h:panelGroup layout="block" style="text-align: right">
                        <p:commandButton value="Сохранить" action="#{mbVFirstName.registration()}"
                                         oncomplete="newFirstNameDlg.hide();" update="tabListFirstName">
                        </p:commandButton>
                        <p:commandButton value="Отменить" oncomplete="newFirstNameDlg.hide();"
                                         action="#{mbVFirstName.cancel()}" />
                    </h:panelGroup>
                </p:dialog>
        
                <!-- Delete FirstName -dialog -->
                <p:dialog widgetVar="deleteFirstNameDlg" id="deleteFirstNameDialog"
                          header="Удаление имени" hideEffect="fade"
                          showEffect="fade" resizable="false" 
                          closable="true">

                    <h:outputText value="Удаляем имя?" />

                      <h:panelGroup layout="block" style="text-align: right">
                          <p:commandButton value="Удалить" action="#{mbVFirstName.remove()}"
                                           oncomplete="deleteFirstNameDlg.hide();" update="tabListFirstName">
                          </p:commandButton>
                          <p:commandButton value="Отменить"
                                           oncomplete="deleteFirstNameDlg.hide();"
                                           action="#{mbVFirstName.cancel()}" />
                      </h:panelGroup>
                </p:dialog> 
                
                <!-- Editing FirstName -dialog -->
                <p:dialog widgetVar="editFirstNameDlg" id="editFirstNameDialog"
                          header="Редактирование имени" hideEffect="fade"
                          showEffect="fade" resizable="false" closable="true">
                    <p:outputLabel value="Имя" for="txtFirstNameUpdate"/>
                    <p:inputText id="txtFirstNameUpdate" label="Имя" size="50" 
                                 value="#{mbVFirstName.firstName.name}"/>
                    <h:panelGroup layout="block" style="text-align: right">
                        <p:commandButton value="Сохранить" action="#{mbVFirstName.update()}"
                                         oncomplete="editFirstNameDlg.hide();" update="tabListFirstName">
                        </p:commandButton>
                        <p:commandButton value="Отменить" oncomplete="editFirstNameDlg.hide();"
                                         action="#{mbVFirstName.cancel()}" />
                    </h:panelGroup>
                </p:dialog>
        </h:form>   
</html>

